package com.itheima.streamdemo1;

import java.util.*;
import java.util.stream.Stream;

public class Demo {

    public static void main(String[] args) {

        //获取Stream流

        //1.获取Collection集合的Stream流：调用Collection提供的stream()方法
        Collection<String> list = new ArrayList<>();        //或用List
        Stream<String> stream1 = list.stream();

        //2.Map集合获取Stream流：
        Map<String,Integer> map = new HashMap<>();
        //获取key的Stream流
        Stream<String> stream2 = map.keySet().stream();
        //获取value的Stream流
        Stream<Integer> stream3 = map.values().stream();
        //获取键值对对象的Stream流
        Stream<Map.Entry<String, Integer>> stream4 = map.entrySet().stream();

        //3.数组获取Stream流：
        String[] arr = {"张三","李四","王五","赵六"};
        Stream<String> stream5 = Arrays.stream(arr);
        System.out.println(stream5.count());

        Stream<String> stream6 = Stream.of(arr);
        Stream<String> stream7 = Stream.of("张三","李四","王五","赵六");

    }
}
